<template>
  <div>child子组件</div>
  <ul>
    <li v-for="item in store.ratedList" :key="item._id">{{ item.title }}</li>
  </ul>
</template>

<script lang="ts" setup>
import { useMoviesStore } from "../../stores/movies";
import { onMounted } from "vue";

const store = useMoviesStore();

onMounted(() => {
  store.getData();
});

// 当仓库的数据发生改变的时候触发
store.$onAction(({ name, store, after }) => {
  // after函数会在actions的函数resolve之后调用
  after(() => {
    console.log(123, name, store);
  });
});
</script>
